﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;

namespace Lyon2_WPF
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        WriteableBitmap display;
        ImageBrush displayBrush;
        int frameCounter = 0;

        public MainWindow()
        {
            InitializeComponent();
            display = new WriteableBitmap(640, 480, 96, 96, PixelFormats.Pbgra32, BitmapPalettes.Halftone256);
            displayBrush = new ImageBrush(display);
            displayBrush.TileMode = TileMode.None;
            Background = displayBrush;
            DispatcherTimer timer = new DispatcherTimer(TimeSpan.FromMilliseconds(1), DispatcherPriority.ApplicationIdle, TimerTick, Dispatcher);
        }

        void InitDisplay()
        {
        }

        void TimerTick(object sender, EventArgs e)
        {
            Random r = new Random();
            int x = r.Next(640);
            int y = r.Next(480);
            display.WritePixels(new Int32Rect(x, y, 1, 1), new Int32[] { -1 }, display.PixelWidth, 0);
            frameCounter++;
            //Title = frameCounter.ToString();
        }
        
    }
}
